<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

require 'defaultController.php';

class memberController extends defaultController {
    function indexAction(){
        $allmemeber=$this->_model('login')->allmember();
        $data['allmember']=$allmemeber;
         $this -> _view('memberlist.tpl.php',$data);
    }
    function infoAction(){
        $id=$this->for_get('id');
        $info=$this->_model('login')->getinfo($id);
        $data['info']=$info;       
        if($this->for_post("addmoney")){
            
            $member=$this->_model('login')->getinfo($id);
            $addmoney=$this->for_post('money');
            $money=$addmoney+$member['money'];
            
            $data=array(
                'money'=>$money
            );
            $result=$this->_model('login')-> updatemember2($data,$id);
            if($result){
                $str="充值".$addmoney;
                $data=array(
                    'title'=> $str,
                    'time'=> date("Y/m/d"),
                    'member_id'=>$id,
                    'class'=>1
                );
                $this->_model('data')->add($data);
                $this->showMessage("充值成功");
            }else{
                 $this->showMessage("充值错误");
            }
        };
        if($this->for_post("addmessage")){
            $message=$this->for_post('message');
            $data=array(
                'content'=>$message,
                'data'=> date("Y/m/d"),
                'member_id'=>$id
            );  
            $result=$this->_model('mess')->add($data);
            if($result){
                $this->showMessage('发送成功');
            }
        }
        $tasklist=$this->_model('task')->alllist2($id);
        $data['tasklist']=$tasklist;
        $data['list']= $this->_model('data')->mlist($id);
        $this -> _view('memberinfo.tpl.php',$data);
    }
    function moneyAction(){  
        $list=$this->_model('taobao')->all1();
        $data['list']=$list;
        $this->_view('mmlist.tpl.php',$data);
    }
    function money2Action(){
        if(!$this->checkadminLogin()){
          $this->redirectPage("index.php?c=admin&a=alogin");
        }
        $s=$this->for_get("s");
        $id=$this->for_get("id");
        $data=array(
            'status'=>$s
                );
         $result=$this->_model('taobao')->update($data,$id);
         if($result){
             $this->showMessage('修改成功');
         }else{
             $this->showMessage('状态未修改');
         }
    }
};